def isevent(name, tag):
    if name in ['onblur', 'onclick', 'ondblclick', 'onfocus', 'onkeydown', 'onkeypress', 'onkeyup', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onload']: return True
    if tag == 'img' and name in ['onabort', 'onload']: return True
    if tag == 'form' and name in ['onreset', 'onsubmit']: return True
    if tag == 'body' and name in ['onload', 'onunload']: return True
    if name == 'onchange' and tag in ['input', 'select', 'textarea']: return True
    if name == 'onselect' and tag in ['input', 'textarea']: return True
    return False

def attrTrans(name, tag):
    if name == 'class': return 'className'
    if tag == 'meta' and name == 'http-equiv': return 'httpEquiv'
    name = name.replace(':','_').replace('-','_')
    return name

def tagTrans(tag, typ):
    if tag == 'a': return 'Anchor'
    if tag == 'area': return 'Area'
    if tag == 'base': return 'Base'
    if tag == 'body': return 'Body'
    if tag == 'button': return 'Button'
    if tag == 'canvas': return 'Canvas'
    if tag == 'form': return 'Form'
    if tag == 'frame': return 'Frame'
    if tag == 'iframe': return 'Iframe'
    if tag == 'img': return 'Image'
    if tag == 'input':
        if typ == 'button': return 'Button'
        if typ == 'checkbox': return 'Checkbox'
        if typ == 'file': return 'FileUpload'
        if typ == 'hidden': return 'Hidden'
        if typ == 'password': return 'Password'
        if typ == 'radio': return 'Radio'
        if typ == 'reset': return 'Reset'
        if typ == 'submit': return 'Submit'
        if typ == 'text': return 'Text'
    if tag == 'link': return 'Link'
    if tag == 'meta': return 'Meta'
    if tag == 'object': return 'Object'
    if tag == 'option': return 'Option'
    if tag == 'select': return 'Select'
    if tag == 'table': return 'Table'
    if tag == 'td': return 'TableCell'
    if tag == 'tr': return 'TableRow'
    if tag == 'textarea': return 'Textarea'

classlist = ['Anchor', 'Area', 'Base', 'Body', 'Button', 'Canvas', 'Form', 'Frame', 'Iframe', 'Image', 'Checkbox', 'FileUpload', 'Hidden', 'Password', 'Radio', 'Reset', 'Submit', 'Text', 'Link', 'Meta', 'Option', 'Select', 'Table', 'TableCell', 'TableRow', 'Textarea']

def classtotag(clsname):
    if clsname == 'Anchor': return 'a'
    if clsname in ['Checkbox', 'FileUpload', 'Hidden', 'Password', 'Radio', 'Reset', 'Submit', 'Text']: return 'input'
    if clsname == 'Image': return 'img'
    if clsname == 'TableCell': return 'td'
    if clsname == 'TableRow': return 'tr'
    return clsname.lower()

class Navigator(object):

    appCodeName = "Mozilla" #Returns the internal "code" name of the current browser. 
    appName = "Microsoft Internet Explorer" #Returns the official name of the browser. 
    appVersion = "4.0 (compatible; MSIE 6.0; Windows NT 5.1)"#Returns the version of the browser as a string. 
    buildID = ""        # Returns the build identifier of the browser (e.g. "2006090803") 
    cookieEnabled = True        #  Returns a boolean indicating whether cookies are enabled in the browser or not.    
    language = ""        #  Returns a string representing the language version of the browser.
    mimeTypes = []        # Returns a list of the MIME types supported by the browser.     
    onLine = True        # Returns a boolean indicating whether the browser is working online.  
    oscpu = ""        # Returns a string that represents the current operating system.     
    platform = ""        # Returns a string representing the platform of the browser.     
    plugins = []        # Returns an array of the plugins installed in the browser.     
    product = ""        # Returns the product name of the current browser. (e.g. "Gecko") 
    productSub = ""        # Returns the build number of the current browser (e.g. "20060909")       
    securityPolicy = ""
               # Returns an empty string. In Netscape 4.7x, returns "US & CA domestic policy" or "Export policy". 
    userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"        
                                    # Returns the user agent string for the current browser.   
    vendor = ""        # Returns the vendor name of the current browser (e.g. "Netscape6")   
    vendorSub = ""        # Returns the vendor version number (e.g. "6.1") 
   
    appMinorVersion = ""
    browserLanguage = ""
    cpuClass = ""
    systemLanguage = "" 	
    userLanguage = "en-us"
      
    #Indicates whether the host browser is Java-enabled or not.   
    def javaEnabled(self, *arg): return True

    #Lets code check to see if the document at a given URI is available without using the network. 
    def mozIsLocallyAvailable(self, *arg): return False
       
    #Sets a user preference. 
    #self method is only available to privileged code, and you should use XPCOM Preferences API instead. 
    def preference(self, *arg): pass
   
    #Allows web sites to register themselves as a possible handler for a given MIME type. 
    def registerContentHandler(self, *arg): pass
   
    #New in Firefox 3         Allows web sites to register themselves as a possible handler for a given protocol. 
    def registerProtocolHandler(self, *arg): pass
  
    #Obsolete       Returns false. JavaScript taint/untaint functions removed in JavaScript 1.2[1] 
    def taintEnabled(self, *arg): return False

class CSSStyleDeclaration(object):
          azimuth =""
          background = "#FFCC80 url(bgdesert.jpg) repeat-y"  
          backgroundAttachment = "fixed"                      
          backgroundColor = "#FFCC80"                         
          backgroundImage = "url(bgdesert.jpg)"       
          backgroundPosition = "bottom center"        
          backgroundRepeat = "repeat-y"               
          border = "thick solid #0000FF"              
          borderBottom = "thick solid blue"           
          borderBottomColor = "blue"                  
          borderBottomStyle = "dotted"               
          borderBottomWidth = "thick"                 
          borderCollapse = "collapse"                
          borderColor = "#0000FF #00FF00"           
          borderLeft = "thick solid #0000FF"       
          borderLeftColor = "#0000FF"             
          borderLeftStyle = "dotted"              
          borderLeftWidth = "thick"               
          borderRight = "thick solid #0000FF"     
          borderRightColor = "#0000FF"            
          borderRightStyle = "dotted"           
          borderRightWidth = "thick"            
          borderSpacing = "10px"               
          borderStyle = "dotted double"        
          borderTop = "thick solid #0000FF"    
          borderTopColor = "#0000FF"           
          borderTopStyle = "dotted"            
          borderTopWidth = "thick thin"        
          borderWidth = "thick thin"           
          bottom = "100px"                     
          captionSide = "right"                                        
          clear = "left"                       
          clip = "rect(0px,50px,50px,0px)"     
          color = "#ff0000"                    
          content = "content"                  
          counterIncrement = "counterIncrement"   
          counterReset = "counterRese"   
          cssFloat = "left"                  
          cssText = "cssText"                
          cue = ""
          cueAfter = ""
          onBefore = ""
          cursor = "text"               
          direction = "rtl"             
          display = "none"              
          elevation = ""
          emptyCells = "show"            
          font = "italic bold 12px arial,serif"   
          fontFamily = "arial,sans-serif"         
          fontSize = "larger"                    
          fontSizeAdjust = "0.70"                
          fontStretch = "ultra-expanded"          
          fontStyle = "italic"                    
          fontVariant = "small-caps"             
          fontWeight = "900"              
          height = "50px"              
          left = "100px"             
          length = ""
          letterSpacing = "3"         
          lineHeight = ""                 
          listStyle = "decimal inside"             
          listStyleImage = 'url("blueb.gif")'     
          listStylePosition = "inside"             
          listStyleType = "square"                
          margin = "100px"             
          marginBottom = "32px"        
          marginLeft = "32px"         
          marginRight = "32px"        
          marginTop = "32px"                       
          markerOffset = "markerOffset"            
          marks = "marks"               
          maxHeight = "10px"           
          maxWidth = "10px"           
          minHeight = "200px"         
          minWidth = "1000px"         
          MozAppearance = ""
          MozBackgroundClip = ""
          MozBackgroundInlinePolicy = ""
          MozBackgroundOrigin = ""
          MozBinding = ""
          MozBorderBottomColors = ""
          MozBorderLeftColors = ""
          MozBorderRadius = ""
          MozBorderRadiusBottomleft = ""
          MozBorderRadiusBottomright = ""
          MozBorderRadiusTopleft = ""
          MozBorderRadiusTopright = ""
          MozBorderRightColors = ""
          MozBorderTopColors = ""
          MozBoxAlign = ""
          MozBoxDirection = ""
          MozBoxFlex = ""
          MozBoxOrient = ""
          MozBoxOrdinalGroup = ""
          MozBoxPack = ""
          MozBoxSizing = ""
          MozColumnCount = ""
          MozColumnGap = ""
          MozColumnWidth = ""
          MozFloatEdge = ""
          MozForceBrokenImageIcon = ""
          MozImageRegion = ""
          MozMarginEnd = ""
          MozMarginStart = ""
          MozOpacity = ""
          MozOutline = ""
          MozOutlineColor = ""
          MozOutlineOffset = ""
          MozOutlineRadius = ""
          MozOutlineRadiusBottomleft = ""
          MozOutlineRadiusBottomtop = ""
          MozOutlineRadiusTopleft = ""
          MozOutlineRadiusTopright = ""
          MozOutlineStyle = ""
          MozOutlineWidth = ""
          MozPaddingEnd = ""
          MozPaddingStart = ""     
          MozUserFocus = ""
          MozUserInput = ""
          MozUserModify = ""
          MozUserSelect = ""
          opacity = ""
          orphans = "orphans"               
          outline = "thin dotted #0000FF"      
          outlineColor = "#00FF00"             
          outlineStyle = "dotted"             
          outlineWidth = "thin"              
          overflow = "hidden"              
          overflowX = ""
          overflowY = ""
          padding = "2cm"                
          paddingBottom = "2cm"         
          paddingLeft = "2cm"            
          paddingRight = "2cm"        
          paddingTop = "2cm"           
          page = "page"                 
          pageBreakAfter = "always"      
          pageBreakBefore = "always"     
          pageBreakInside = "avoid"   
          parentRule = ""
          pause = ""
          pauseAfter = ""
          pauseBefore = ""
          pitch = ""
          pitchRange = ""
          playDuring = ""
          position = "absolute"      
          quotes = "none"            
          richness = ""
          right = "100px"           
          size = "size"             
          speak = ""
          speakHeader = ""
          speakNumeral = ""
          speakPunctuation = ""
          speechRate = ""
          stress = ""
          tableLayout = "fixed"     
          textAlign = "right"        
          textDecoration = "overline"     
          textIndent = "50px"               
          textShadow = "textShadow"         
          textTransform = "capitalize"      
          top = "100px"                    
          unicodeBidi = "unicodeBidi"
          verticalAlign = "bottom"               
          visibility = "hidden"                  
          voiceFamily = ""
          volume = ""
          whiteSpace = "nowrap"          
          widows = "widows"                             
          width = "300px"                
          wordSpacing = "10px"           
          zIndex  = "1"              

          backgroundPositionX = "right "  	
          backgroundPositionY = "bottom"     	
          scrollbar3dLightColor = "blue"  	  	
          scrollbarArrowColor = "blue" 	 	
          scrollbarBaseColor = "blue" 	 	
          scrollbarDarkShadowColor = "blue" 	 	
          scrollbarFaceColor = "blue" 	 	
          scrollbarHighlightColor = "blue" 	 	
          scrollbarShadowColor = "blue" 	 	
          scrollbarTrackColor = "blue" 	
          

          dir = "rtl" 	  	
          lang = "en" 	 
          title = "title"	

